package demo.pattern.proxy.cglib;

import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;

/**
 * @ClassName CglibUtil
 * @Description
 * @Author 47980
 * @Date 2020/8/9 16:07
 * @Version V_1.0
 **/
public class CglibUtil {
    /**
     * 创建动态代理的类
     * @param targetObject
     * @param methodInterceptor
     * @param <T>
     * @return
     */
    public static <T>T createProxy(T targetObject, MethodInterceptor methodInterceptor) {
        return (T) Enhancer.create(targetObject.getClass(), methodInterceptor);
    }
}
